<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <h2>for和if</h2>

    <ul>
      <!-- 在vue3版本，v-if具有比v-for更高的优先级 -->
      <!-- <li v-for="item in list" v-if="item % 2">{{ item }}</li> -->

      <!-- <template v-for="item in list">
        <li v-if="item % 2">{{ item }}</li>
      </template> -->
      
      <li v-for="item in oddList">{{ item }}</li>
    </ul>
  </div>

  <script src="../vue3.js"></script>
  <script>

    const {createApp} = Vue;
    createApp({
      data() {
        return {
          list: [1,2,3,4,5,6,7,8,9],
        }
      },
      computed: {
        oddList() {
          return this.list.filter(item => item % 2)
        }
      }
    }).mount("#app");
  </script>
</body>
</html>